<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script type="text/javascript">
	function languageSelecter_onChanged(languageSelecter) {
		window.location.href=updateUrlParam(languageSelecter.name,languageSelecter.value,window.location.href);
	}
	function updateUrlParam(para_name,para_value,url){
	        var strNewUrl=new String();
	        var strUrl=url;
	        if(strUrl.indexOf("?")!=-1){
	            strUrl=strUrl.substr(strUrl.indexOf("?")+1);
	            if(strUrl.toLowerCase().indexOf(para_name.toLowerCase())==-1){
	                strNewUrl=url+"&"+para_name+"="+para_value;
	                return strNewUrl;
	            }else{
	                var aParam=strUrl.split("&");
	                for(var i=0;i<aParam.length;i++){
	                    if(aParam[i].substr(0,aParam[i].indexOf("=")).toLowerCase()==para_name.toLowerCase()){
	                       aParam[i]= aParam[i].substr(0,aParam[i].indexOf("="))+"="+para_value;
	                    }
	                }
	               strNewUrl=url.substr(0,url.indexOf("?")+1)+aParam.join("&");
	               return strNewUrl;
	           }
	        }else{
	            strUrl+="?"+para_name+"="+para_value;
	            return strUrl
	        }
	}
</script>
<s:set name="SESSION_LOCALE" value="#session['WW_TRANS_I18N_LOCALE']" />
<div align="right" id="languageSelecterDiv">
	<s:select label="Lanaguage" list="languages.locales" listKey="value"
		listValue="key"
		value="#SESSION_LOCALE==NULL?(languages.locales.containsValue(locale)?locale:languages.defaultLocale):#SESSION_LOCALE"
		name="request_locale" id="langSelecter"
		onchange="languageSelecter_onChanged(this)" theme="simple" />
</div>